package com.zmj.sy.mom.srv.aps.controller;

import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseListResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.consistency.ConsistencyCheckReqVo;
import com.zmj.sy.mom.srv.aps.bean.vo.consistency.ConsistencyCheckResVo;
import com.zmj.sy.mom.srv.aps.service.ConsistencyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequiredArgsConstructor
@Api(tags = "一致性")
@RestController
@RequestMapping("/consistency")
public class ConsistencyController {

    private final ConsistencyService consistencyService;

    @ApiOperation("BOM一致性对比")
    @GetMapping("/check")
    public BaseListResVo<ConsistencyCheckResVo> check(ConsistencyCheckReqVo reqVo) {
        if(!StringUtils.hasText(reqVo.getConstructionCode())){
            return BaseListResVo.empty();
        }

        reqVo.setConstructionCode(reqVo.getConstructionCode().toUpperCase().trim());

        return consistencyService.check(reqVo);
    }

    @ApiOperation("施工号下拉框查询")
    @GetMapping("/conCode")
    public BaseListResVo<String> conCode(ConsistencyCheckReqVo reqVo) {
        return consistencyService.conCode(reqVo);
    }

    @ApiOperation("异常原因下拉框")
    @GetMapping("/diffMsg")
    public BaseListResVo<String> diffMsg() {
        return consistencyService.diffMsg();
    }

}
